using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace WOWEquipOptimizer
{
    /// <summary>
    /// Gem m_Items, inherits m_Items
    /// </summary>
    public class Gem : Item
    {
        private GemType m_Type = GemType.None;
        public GemType Type
        {
            get { return m_Type; }
            set { m_Type = value; }
        }
        public static Gem None = new Gem();
        /// <summary>
        /// parses gem type
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public static GemType parseGemType(string desc)
        {
            
            string[] splitted = desc.Split(new char[] { ' ',',','.' },StringSplitOptions.RemoveEmptyEntries);
            GemType retval = GemType.None;
            for (int i = 0; i < splitted.Length; i++)
            {
                try
                {
                    GemType test = (GemType)Enum.Parse(typeof(GemType), splitted[i], true);
                    if (retval == GemType.None)
                    {
                        retval = test;
                    }
                    else
                    {
                        retval |= test;
                    }
                }
                catch (Exception)
                {
                }
            }
            return retval;
        }

    }
}
